package com.endoc.endocbtool.ui.adapter;
import android.widget.TextView;
import androidx.databinding.BindingAdapter;

/**
 * BindingAdapter是不让在Activity中或者fragment中去更新ui,虽然dataBinding将数据和ui直接绑定了,更新的数据只是url,需要去加载后才能显示真正的图片,所以需要在Adapter中更新
 */
public class MainActivityBindingAdapter {

  @BindingAdapter(value = {"searchStatus"},requireAll = true)
    public static void showSearchText(TextView textView,boolean searchStatus){
        //Logger.d("搜索状态改变");
        if(searchStatus){
            textView.setText("停止搜索");
        }else {
            textView.setText("开始搜索");
        }
    }


    @BindingAdapter(value = {"connectStatus","deviceName"},requireAll = false)
    public static void showConnectStatus(TextView textView,boolean connectStatus,String deviceName){
        //Logger.d("连接状态改变");
        if(connectStatus){
            //提示用户可以断开蓝牙
            textView.setText("断开");
        }else {
            //提示用户可以连接蓝牙
            textView.setText("连接");
        }
    }
}
